﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCS.Infrastructure.Dto.Response.Epaylinks;

namespace WCS.Infrastructure.Dto.Request.Epaylinks
{
    /// <summary>
    /// 分账商户提现请求对象
    /// </summary>
    public class SubMerchantWithdrawalRequest
    {
        /// <summary>
        /// 版本号，默认3.0
        /// </summary>
        public string Version { get; set; }

        /// <summary>
        /// 商户编号(version>=2.0时使用)(平台商户编号)
        /// </summary>
        public string CustomerCode { get; set; }

        /// <summary>
        /// 提现的商户订单号
        /// </summary>
        public string? OutTradeNo { get; set; }

        /// <summary>
        /// 分账商户编号
        /// </summary>
        public string MemberId { get; set; }

        /// <summary>
        /// 绑卡协议号
        /// </summary>
        public string? Protocol { get; set; }

        /// <summary>
        /// 提现金额，单位分
        /// </summary>
        public long? PayAmount { get; set; }

        /// <summary>
        /// 到账类型：0-当日到账(默认)，1-次日到账，依此类推
        /// </summary>
        public int ArrivalType { get; set; } = 0;

        /// <summary>
        /// 银行卡标签（传入此值时，就按此值结算卡信息结算；不传时按默认结算卡信息结算）
        /// </summary>
        public string? BankCardId { get; set; }

        /// <summary>
        /// 是否全额：0-非全额(默认)，1-全额
        /// </summary>
        public int IsFullAmount { get; set; } = 1;

        /// <summary>
        /// 手续费扣除商户（默认为空则为memberId）
        /// </summary>
        public string? ProcedureCustomerCode { get; set; }

        /// <summary>
        /// 商户服务费，单位分
        /// </summary>
        public long? ServiceFee { get; set; } = 0;

        /// <summary>
        /// 支付币种，默认CNY
        /// </summary>
        public string PayCurrency { get; set; }

        /// <summary>
        /// 异步通知地址
        /// </summary>
        public string? NotifyUrl { get; set; }

        /// <summary>
        /// 备注信息
        /// </summary>
        public string Remark { get; set; }

        /// <summary>
        /// 摘要
        /// </summary>
        public string Summary { get; set; }

        /// <summary>
        /// 随机字符串
        /// </summary>
        public string? NonceStr { get; set; }
    }

    /// <summary>
    /// 新增提现记录请求参数
    /// </summary>
    public class AddWithdrawalRequest
    {
        /// <summary>
        /// 用户ID
        /// </summary>
        public string? UserId { get; set; }
        /// <summary>
        /// 商户ID
        /// </summary>
        public string? MerchantId { get; set; }
        /// <summary>
        /// 商户编号(version>=2.0时使用)(平台商户编号)
        /// </summary>
        public string? CustomerCode { get; set; }
        /// <summary>
        /// 分账商户编号
        /// </summary>
        public string? MemberId { get; set; }
        /// <summary>
        /// 提现金额，单位分
        /// </summary>
        public long? PayAmount { get; set; }
        /// <summary>
        /// 提现金额  
        /// </summary>
        public long Amount { get; set; }
        /// <summary>
        /// 手续费
        /// </summary>
        public long Fee { get; set; }
        /// <summary>
        /// 费率
        /// </summary>
        public decimal? FeeRate { get; set; }
        /// <summary>
        /// 实际到账金额
        /// </summary>
        public long ActualAmount { get; set; }
        /// <summary>
        /// 分账记录ID
        /// </summary>
        public string? EpaylinksSplitRecordId { get; set; }
    }

    /// <summary>
    /// 分账商户提现响应对象
    /// </summary>
    public class SubMerchantWithdrawalResponse:EpaylinksResponseDto
    {

        /// <summary>
        /// 商户编号
        /// </summary>
        public string CustomerCode { get; set; }

        /// <summary>
        /// 分账商户编号
        /// </summary>
        public string MemberId { get; set; }

        /// <summary>
        /// 服务费收取状态：1-服务费扣取成功，0-未扣取服务费
        /// </summary>
        public int? ServiceFeeState { get; set; }

        /// <summary>
        /// 易票联订单号
        /// </summary>
        public string TransactionNo { get; set; }

        /// <summary>
        /// 提现金额，单位分
        /// </summary>
        public long? Amount { get; set; }

        /// <summary>
        /// 手续费，单位分
        /// </summary>
        public long? ProcedureFee { get; set; }

        /// <summary>
        /// 手续费扣除商户
        /// </summary>
        public string ProcedureCustomerCode { get; set; }

        /// <summary>
        /// 实际提现到账金额，单位分
        /// </summary>
        public long? ActualFee { get; set; }

        /// <summary>
        /// 支付结果
        /// </summary>
        public string PayResult { get; set; }

        /// <summary>
        /// 原因说明
        /// </summary>
        public string ChannelQueryMsg { get; set; }

        /// <summary>
        /// 随机字符串
        /// </summary>
        public string NonceStr { get; set; }
    }

    /// <summary>
    /// 分账商户提现结果异步通知请求对象(:结果查询同步响应对象)
    /// </summary>
    public class SubMerchantWithdrawalResultNotificationRequestDto:EpaylinksResponseDto
    {
        /// <summary>
        /// 商户编号
        /// </summary>
        public string CustomerCode { get; set; }

        /// <summary>
        /// 商户订单号
        /// </summary>
        public string OutTradeNo { get; set; }

        /// <summary>
        /// 易票联订单号
        /// </summary>
        public string TransactionNo { get; set; }

        /// <summary>
        /// 提现金额，单位为分
        /// </summary>
        public long Amount { get; set; }

        /// <summary>
        /// 到账类型，默认0
        /// </summary>
        public int? ArrivalType { get; set; } = 0;

        /// <summary>
        /// 提现状态
        /// </summary>
        public string PayState { get; set; }

        /// <summary>
        /// 服务费收取状态
        /// </summary>
        public int? ServiceFeeState { get; set; }

        /// <summary>
        /// 手续费，单位分
        /// </summary>
        public long? ProcedureFee { get; set; }

        /// <summary>
        /// 手续费扣除商户
        /// </summary>
        public string? ProcedureCustomerCode { get; set; }

        /// <summary>
        /// 提现完成时间，格式：YYYYMMDDHHMMSS
        /// </summary>
        public string? PayTime { get; set; }

        /// <summary>
        /// 原因说明
        /// </summary>
        public string? ChannelQueryMsg { get; set; }

        /// <summary>
        /// 渠道类型
        /// </summary>
        public string? ChannelType { get; set; }

        /// <summary>
        /// 收款人姓名
        /// </summary>
        public string? BankUserName { get; set; }

        /// <summary>
        /// 银行卡号
        /// </summary>
        public string? BankCardNo { get; set; }

        /// <summary>
        /// 银行名称
        /// </summary>
        public string? BankName { get; set; }

        /// <summary>
        /// 随机字符串
        /// </summary>
        public string NonceStr { get; set; }
    }


    /// <summary>
    /// 分账商户提现结果查询请求对象
    /// </summary>
    public class SubMerchantWithdrawalResultQueryRequestDto
    {
        /// <summary>
        /// 版本号
        /// </summary>
        public string? Version { get; set; } = "3.0";

        /// <summary>
        /// 商户编号
        /// </summary>
        public string? CustomerCode { get; set; }

        /// <summary>
        /// 分账商户编号
        /// </summary>
        public string? MemberId { get; set; }

        /// <summary>
        /// 商户订单号
        /// </summary>
        public string? OutTradeNo { get; set; }

        /// <summary>
        /// 易票联订单号（不 outTradeNo 二选一，不outTradeNo 同时存在时，优先使用transactionNo 查询）
        /// </summary>
        public string? TransactionNo { get; set; }

        /// <summary>
        /// 随机字符串
        /// </summary>
        public string? NonceStr { get; set; }
    }
}
